package im.xz.cn.xiacore.auth;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Objects;
public class authMain implements CommandExecutor {
    Plugin plugin = im.xz.cn.xiacore.XiaCore.getPlugin(im.xz.cn.xiacore.XiaCore.class);
    @Override
    public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
        Player player = (Player) commandSender;
        try {
            String password = Arrays.toString(Encode.SHAEncode(Objects.requireNonNull(plugin.getConfig().getString("key")).getBytes()));
            Boolean yes = false;
            try {
                if (password.equalsIgnoreCase("[数据删除]")) {
                    yes = true;
                }else {
                    yes = false;
                }
            }catch (NullPointerException ignore) {
            }
            if (yes) {
                player.sendMessage(ChatColor.GREEN + "验证成功！您正在正版服务器上游玩！");
            }else {
                player.sendMessage(ChatColor.RED + "验证失败！您可能是盗版受害者！此服务器可能是偷来的！");
                player.sendMessage(ChatColor.RED + "");
                player.sendMessage(ChatColor.RED + "此服务器全部由夏至锐（xzrui）修改与编写。此副本只被授权给了以下服务器 ： 繁星梦（starsDream）。以上服务器的IP地址分别是 ： starsdream.top。如果你在其他服务器找到了这个副本，这一定是盗版。请联系我如果你发现这是一个盗版。我的联系方式：QQ1214621621。谢谢！");
            }
        }catch (NullPointerException ignore) {
        }
        return false;
    }
}